package com.restkeeper.response.exception;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.Map;

/**
 * 异常拦截
 *
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Object Exception(Exception ex) {
//        Map<String, Object> errorMap = new HashMap<String, Object>();
//        errorMap.put("errCode", "00000");
//        errorMap.put("errMessage", ex.getMessage());
//        return errorMap;
        ExceptionResponse response =new ExceptionResponse(ex.getMessage());
        return response;
    }
}
